package io.zhengsh.order.tool;

import lombok.Data;
import org.springframework.beans.BeanUtils;

public class BeanUtilsTest {

    public static void main(String[] args) {
        UserDto userDto = new UserDto();
        userDto.setName("张三");
        userDto.setName("138888888888");
        AddressDto address = new AddressDto();
        address.setPhone("13888888111");
        address.setName("张三三");
        address.setAddressDetail("北京-海淀");
        userDto.setAddress(address);

        UserDto userDto1 = new UserDto();
        BeanUtils.copyProperties(userDto, userDto1);

        System.out.println("userDto1.address.addressDetail" + userDto1.getAddress().getAddressDetail());
        address.setAddressDetail("北京-朝阳");
        System.out.println();
        System.out.println("userDto.address.addressDetail" + userDto.getAddress().getAddressDetail());
        System.out.println("userDto1.address.addressDetail" + userDto1.getAddress().getAddressDetail());
    }
}

@Data
class UserDto {
    private String name;
    private String phone;
    private AddressDto address;
}

@Data
class AddressDto {
    private String name;
    private String phone;
    private String addressDetail;
}


